package com.codedancer.campus.enums;

import cn.hutool.core.util.ObjectUtil;
import com.codedancer.campus.common.enums.CodeDbEnum;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Author codeworld 失物招领物品类型 主要是 拾取到物品和丢失物品
 **/
public enum LostFoundItemType implements CodeDbEnum {

    PICK_UP(1, "拾取"),
    LOST(2, "丢失");


    /**
     * 对应的值
     */
    @JsonValue
    private final Integer value;

    /**
     * 对应的名称
     */
    private final String name;

    LostFoundItemType(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static LostFoundItemType fromValue(Integer value) {
        for (LostFoundItemType lostFoundItemType : LostFoundItemType.values()) {
            if (ObjectUtil.equal(lostFoundItemType.getValue(), value)) {
                return lostFoundItemType;
            }
        }
        return null;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
